namespace FreeWorkflow.DataAccess.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class RenameTaskstoWorkItem : DbMigration
    {
        public override void Up()
        {
            DropForeignKey("fwf.Tasks", "AssignedTo_Id", "fwf.Users");
            DropForeignKey("fwf.Tasks", "ClosedBy_Id", "fwf.Users");
            DropIndex("fwf.Tasks", new[] { "AssignedTo_Id" });
            DropIndex("fwf.Tasks", new[] { "ClosedBy_Id" });
            CreateTable(
                "fwf.WorkItem",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        Title = c.String(),
                        Outcome = c.String(),
                        DateCreated = c.DateTime(nullable: false),
                        DateClosed = c.DateTime(),
                        AssignedTo_Id = c.String(maxLength: 128),
                        ClosedBy_Id = c.String(maxLength: 128),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("fwf.Users", t => t.AssignedTo_Id)
                .ForeignKey("fwf.Users", t => t.ClosedBy_Id)
                .Index(t => t.AssignedTo_Id)
                .Index(t => t.ClosedBy_Id);
            
            DropTable("fwf.Tasks");
        }
        
        public override void Down()
        {
            CreateTable(
                "fwf.Tasks",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        Title = c.String(),
                        Outcome = c.String(),
                        DateCreated = c.DateTime(nullable: false),
                        DateClosed = c.DateTime(),
                        AssignedTo_Id = c.String(maxLength: 128),
                        ClosedBy_Id = c.String(maxLength: 128),
                    })
                .PrimaryKey(t => t.Id);
            
            DropForeignKey("fwf.WorkItem", "ClosedBy_Id", "fwf.Users");
            DropForeignKey("fwf.WorkItem", "AssignedTo_Id", "fwf.Users");
            DropIndex("fwf.WorkItem", new[] { "ClosedBy_Id" });
            DropIndex("fwf.WorkItem", new[] { "AssignedTo_Id" });
            DropTable("fwf.WorkItem");
            CreateIndex("fwf.Tasks", "ClosedBy_Id");
            CreateIndex("fwf.Tasks", "AssignedTo_Id");
            AddForeignKey("fwf.Tasks", "ClosedBy_Id", "fwf.Users", "UserId");
            AddForeignKey("fwf.Tasks", "AssignedTo_Id", "fwf.Users", "UserId");
        }
    }
}
